package com.ccnf.core.exception;

import com.ccnf.core.bean.StatusCode;
import lombok.Data;

/**
 * 业务处理相关的异常抛出，所有的异常都继承该异常
 */
@Data
public class BizException extends RuntimeException {
    /**
     * 微信分发门票数为零
     */
    public static final int WEI_XIN_TICKET_ZERO = 701;

    /**
     * 微信分发门票超时
     */
    public static final int WEI_XIN_TICKET_OVER = 702;

    /**
     * 用户已领取其他展商门票
     */
    public static final int TICKET_RECEIVE_OTHER = 703;

    /**
     * 用户已领取该微信分发门票
     */
    public static final int WEI_XIN_TICKET_RECEIVE = 704;

    /**
     * 用户不能领取自己分发的门票
     */
    public static final int TICKET_RECEIVE_SELF = 705;

    /**
     * 门票数不足
     */
    public static final int TICKET_TOTAL_EMPTY = 706;

    /**
     * 展商不能领取门票
     */
    public static final int TICKET_RECEIVE_ROLE = 707;

    /**
     * 用户门票需要入场登记
     */
    public static final int TICKET_NO_REGISTER = 708;

    /**
     * 门票已经作废
     */
    public static final int TICKET_IS_DELETED = 709;

    /**
     * 名称已经重复
     */
    public static final int NAME_IS_EXIST = 808;
    private Integer errorCode;

    public BizException(String message) {
        this(StatusCode.BIZ_OPERATION_FAILURE.code, message);
    }

    public BizException(Integer errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public BizException(StatusCode statusCode, String message) {
        super(message);
        this.errorCode = statusCode.code;
    }
}